/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package datas;

import Beans.UserInterest;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**

 @author jtanguay
 */
public interface UserInterestMapper {

  final String SELECT_USER_INTEREST_FOR_USER = "select * from user_interests where idUser = #{idUser}";
  final String INSERT_INTEREST = "Insert into user_interests ( idUser, idInterest ) VALUES ( #{idUser}, #{idInterest} )";
  final String DELETE_INTEREST = "Delete From user_interests Where idUser=#{idUser} AND idInterest=#{idInterest} ";

  @Select(SELECT_USER_INTEREST_FOR_USER)
  @Results(value = {
    @Result(property = "userId", column = "idUser"),
    @Result(property = "idInterest", column = "idInterest"),
    @Result(property = "idUserInterest", column = "iduser_interests")
  })
  List<UserInterest> getallInterestForUser(int idUser);

  @Insert(INSERT_INTEREST)
  int insertInterest(@Param("idUser") int idUser, @Param("idInterest") int idInterest);

  @Delete(DELETE_INTEREST)
  int deleteInterest(@Param("idUser") int idUser, @Param("idInterest") int idInterest);
}
